﻿using System;
using System.Html.DOM;

namespace enyo
{
    public class Input : Control
    {
        public string Hint { get; set; }
        public string Value { get; set; }
        public int TabIndex { get; set; }
        public bool Spellcheck { get; set; }
        public bool Autocorrect { get; set; }
        public AutoKeyModifier AutoKeyModifier { get; set; }

        public AutoCapitalize AutoCapitalize { get; set; }

        /// <summary>
        /// Set to true to enable auto-emoticons support.
        /// </summary>
        public bool AutoEmoticons { get; set; }

        /// <summary>
        /// Set to true to enable auto-linking support.
        /// </summary>
        public bool AutoLinking { get; set; }

        /// <summary>
        /// Set to false to disable automatic word completion.
        /// </summary>
        public bool AutoWordComplete { get; set; }

        /// <summary>
        /// Specifies the 'type' attribute on the input field.
        /// On webOS, this modifies the virtual keyboard layout. Supported values are "email" and "url".
        /// </summary>
        public InputType InputType { get; set; }

        /// <summary>
        /// CSS class to apply to the inner input control
        /// </summary>
        public string InputClassName { get; set; }

        /// <summary>
        /// CSS class to apply on focus
        /// </summary>
        public string FocusClassName { get; set; }

        /// <summary>
        /// CSS class to apply to inner controls to control spacing
        /// </summary>
        public string SpacingClassName { get; set; }

        /// <summary>
        /// Set to true to make the input look focused when it's not.
        /// </summary>
        public bool AlwaysLooksFocused { get; set; }

        /// <summary>
        /// The selection property is an object describing selected text. The start and end properties specify the zero-based starting and ending indexes of the selection. 
        /// For example, if an input value is "Value" and getSelection returns {start: 1, end: 3}, then "al" is selected.
        /// To select "alu," call: this.$.input.setSelection({start: 1, end: 4});
        /// </summary>
        public TextSelect Selection { get; set; }

        /// <summary>
        /// Set to true to fire the onchange event as well as the oninput event whenever the input content is changed.
        /// </summary>
        public bool ChangeOnInput { get; set; }

        /// <summary>
        /// Set to the number of milliseconds to delay the input event when a key is pressed. 
        /// If another key is pressed within the delay interval, the input will be postponed and fired once only after the delay has elapsed without a key being pressed.
        /// </summary>
        public int KeypressInputDelay { get; set; }

        /// <summary>
        /// Set to false to avoid any default styling from being applied.
        /// </summary>
        public bool Styled { get; set; }

        /// <summary>
        /// Set to true to select all text when the input gains focus.
        /// </summary>
        public bool SelectAllOnFocus { get; set; }



        public EnyoEvent<Control, DomEvent> onfocus;
        public EnyoEvent<Control, DomEvent> onblur;
        public EnyoEvent<Control, DomEvent, object> onchange;
        public EnyoEvent<Control, DomEvent, object> oninput;

        /// <summary>
        /// The onkeypress event can be used to filter out disallowed characters.
        /// </summary>
        public EnyoEvent<Control, object/*TODO:int evt.keyCode*/> onkeypress;


        /// <summary>
        /// Forces this input to be blurred (lose focus).
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="sync"></param>
        public void ForceBlur(Delegate callback, bool sync)
        {
        }

        /// <summary>
        /// Forces this input to be focused.
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="sync"></param>
        public void ForceFocus(Delegate callback, bool sync)
        {
        }

        /// <summary>
        /// Forces this input to be focused and sets the keyboard to automatic mode.
        /// </summary>
        public void ForceFocusEnableKeyboard()
        {
        }

        /// <summary>
        /// Forces selection of all text in this input.
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="sync"></param>
        public void ForceSelect(Delegate callback, bool sync)
        {
        }

        /// <summary>
        /// Returns true if the input has keyboard focus.
        /// </summary>
        /// <returns></returns>
        public bool HasFocus()
        {
            return false;
        }

        public bool IsEmpty()
        {
            return false;
        }
    }
}
